import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _isNumber from "lodash/isNumber";

/**
 * TextArea.js
 * @date 2018/11/14
 */
import React from 'react';
import { Form, InputNumber } from 'antd';
// import intl from 'utils/intl';
import { attributeNameProp, attributeTypeProp, attributeValueProp } from "../../config";
import DataType from "../../DataType";
var inputComponentStyle = {
  width: '100%'
};

var FieldTextArea = /*#__PURE__*/function (_React$Component) {
  _inherits(FieldTextArea, _React$Component);

  var _super = _createSuper(FieldTextArea);

  function FieldTextArea() {
    _classCallCheck(this, FieldTextArea);

    return _super.apply(this, arguments);
  }

  _createClass(FieldTextArea, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          form = _this$props.form,
          _this$props$propValue = _this$props.propValues,
          propValues = _this$props$propValue === void 0 ? {} : _this$props$propValue;
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Form.Item, {
        key: "autoSizeMinRows",
        label: "\u6700\u5C0F\u884C\u6570"
      }, form.getFieldDecorator('autosize.minRows', {
        initialValue: propValues['autosize.minRows'],
        rules: [{
          type: 'number'
        } // TODO 最小行数 必须小于 最大行数
        ]
      })( /*#__PURE__*/React.createElement(InputNumber, {
        style: inputComponentStyle,
        min: 0,
        precision: 0,
        step: 1
      }))), /*#__PURE__*/React.createElement(Form.Item, {
        key: "autoSizeMaxRows",
        label: "\u6700\u5927\u884C\u6570"
      }, form.getFieldDecorator('autosize.maxRows', {
        initialValue: propValues['autosize.maxRows'],
        rules: [{
          type: 'number'
        } // TODO 最大行数 必须大于 最小行数
        ]
      })( /*#__PURE__*/React.createElement(InputNumber, {
        style: inputComponentStyle,
        min: 0,
        precision: 0,
        step: 1
      }))));
    }
  }]);

  return FieldTextArea;
}(React.Component);

export { FieldTextArea as default };
export function getConfigOfPropValues(propValues) {
  var newConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

  if (_isNumber(propValues.autosize.minRows)) {
    var _newConfig$push;

    newConfig.push((_newConfig$push = {}, _defineProperty(_newConfig$push, attributeNameProp, 'autosize.minRows'), _defineProperty(_newConfig$push, attributeValueProp, propValues.autosize.minRows), _defineProperty(_newConfig$push, attributeTypeProp, DataType.Number), _newConfig$push));
  }

  if (_isNumber(propValues.autosize.maxRows)) {
    var _newConfig$push2;

    newConfig.push((_newConfig$push2 = {}, _defineProperty(_newConfig$push2, attributeNameProp, 'autosize.maxRows'), _defineProperty(_newConfig$push2, attributeValueProp, propValues.autosize.maxRows), _defineProperty(_newConfig$push2, attributeTypeProp, DataType.Number), _newConfig$push2));
  }

  return newConfig;
}
export var lifeUpgrade = [];
FieldTextArea.getConfigOfPropValues = getConfigOfPropValues;
FieldTextArea.lifeUpgrade = lifeUpgrade;